<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Store extends Model
{
    use HasFactory;
    protected $table = 'zfm_store';
    protected $guarded = [];

    //关联门店评论表
    public function comments()
    {
        return $this->hasMany(Comments::class);
    }

    /**
     * @return Store[]|\Illuminate\Database\Eloquent\Collection
     * 门店数据展示
     * @yuankai
     */
    public static function list($paginate)
    {
        return self::paginate($paginate);
    }

    /**
     * 门店数据查找
     * @param $where
     * @return mixed
     * @yuankai
     */
    public static function search($store_name){
        return self::where($store_name)->get();
    }

    /**
     * 门店数据删除
     * @yuankai
     */
    public static function del($id,$store_id){
        return self::where([$id=>$store_id])
            ->delete();
    }

    /**
     * 门店详情
     * @yuankai
     */
    public static function detail($id,$where){
        return self::where($id,$where)->first();
    }

    /**
     * 门店信息修改
     * @yuankai
     */
    public static function modify($field,$id,$update){
        return self::where($field,$id,$id)->update($update);
    }
}
